package com.mobis.search.service;

import com.mobis.search.dao.ArticleDao;
import com.mobis.search.pojo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

@Service
public class ArticleSearchService {

    @Autowired
    private ArticleDao articleDao;

    public void add(Article article){
        articleDao.save(article);
    }

    public Page<Article> findByTitleOrContent(String title,String content,int page,int size){

        PageRequest pageRequest=PageRequest.of(page,size);
        Page<Article> pagedate=articleDao.findByTitleOrConntentLike(title,content,pageRequest);
        return  pagedate;

    }
}
